# coding=utf-8
from card_base import CardBase
from sgs.common.constants import userState, cardType
from sha import Sha

class JueDou(CardBase):
    name = '决斗'
    def __init__(self, id, color, point):
        CardBase.__init__(self, id, color, point, cardType.NON_DELAY_SKILL)
        
    def action(self, cond, src, args):
        while len(args) != 1:
            src.addCmd('BROKE_RULE', ['与谁决斗？'])
            cmd, args = src.requireCmd(cond, 'REQ_TARGET', respCmds=['SET_TARGET'])
        src.removeCard(self.id)
        target = src.game.getUser(int(args[0]))
        card = target.requireCard(cond, condition={'class': Sha},
            msg='%s欲与你决斗，请出【杀】' % src.name)
        roundFrom, roundTo = src, target
        while card:
            roundTo.removeCard(card.id)
            roundFrom, roundTo = roundTo, roundFrom
            card = roundTo.requireCard(cond, condition={'class': Sha},
                            msg='%s回敬了【杀】，请出【杀】' % roundFrom.name)
        roundTo.beDamage(cond, roundFrom, self, -1)        
            